
#ifndef _MEMBER_BLight_H_
#define _MEMBER_BLight_H_

#include <BColorf>
#include <BScene>
#include <BProgram>

#include "member_BScene.h"

#define light_member(light)		((member_BLight*)((BLight*)light)->_ptr)

namespace BWE
{
	class member_BLight
	{
	public:
		member_BLight(BLight* light);
		~member_BLight();

		bool freshFrustum();

		bool prepare(const BScene* scene);
		void prepare(SceneOctTreeItem& item);
		void prepare(BGroup* group);
		void prepareShapes(BSet<BNodeHolder>& nodes, BSet<BShapeHolder>& shapes);

		void frameShadow(const BScene* scene);
		void drawShape(ShapeInfo& sinfo, BRender* render);

		BLight*			boss;
		int				shadowSize;
		int				samples;
		BColor			ambient;
		BColor			diffuse;
		BColor			specular;
		float			attenuation;
		float			attenuation2;
		float			exponent;
		float			cutoff;
		BReal			radius;
		BColorf			ambientColor;
		BColorf			diffuseColor;
		BColorf			specularColor;

		bool			dirty;
		bool			resized;
		BFrustum		frustum;
		BReal			near;
		BReal			far;
		BReal			halfSize;
		BVector			center;
		BVector			direct;
		BVector			right;
		BVector			up;

		BUInt				fbo;
		BUInt				rbo;
		BUInt				tbo;
		BUInt				msfbo;
		BUInt				msrbo;
		BUInt				mstbo;
		BUInt				shadowMaps;
		BProgramHolder		shadowProgram;
		BMatrix				modelViewMatrix;
		BMatrix				projectionMatrix;
		BMatrix				entireMatrix;

		SceneOctTreeItemArray	sceneItems;
		ShapeInfoArray		shapeArray;
		ShapeInfoQueue		transShapeQueue;
	};
}

#endif
